package mvc;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;
/**
 * 
 * @author Andrea Pasquali
 *
 */
public class CirclePanel extends JPanel implements Observer{

	private static final long serialVersionUID=0;
	
	
	private Circle circle;
	/**
	 * 
	 * @param circle Cerchio da disegnare
	 */
	public CirclePanel (Circle circle){
		
		super();
		this.circle=circle;
		circle.addObserver(this);
		
	}
	
	/**
	 * Metodo che aggiorna il pannello
	 */
	@Override
	public void update(Observable graphics, Object arg1) {
		repaint();
		
	}
	
	
	protected void paintComponent(Graphics graphics){
		super.paintComponent(graphics);
		
		int x=circle.getX();
		int y=circle.getY();
		int r=circle.getR();
		graphics.setColor(Color.BLUE);
		graphics.fillOval(x-r, y-r, 2*r, 2*r);
	}
	
	
	
	
}
